﻿#Court Maintenance events of various persuasions

namespace = court_maintenance_ua

#Children should acquire personality trait events
court_maintenance_ua.0000 = { #from court_maintenance.0003
	hidden = yes

	trigger = {
		OR = {
			is_adult = no
			any_courtier_or_guest = {
				is_adult = no
			}
			any_prisoner = {
				is_adult = no
			}
			is_ua_adult_preadult = yes
			any_courtier_or_guest = {
				is_ua_adult_preadult = yes
			}
			any_prisoner = {
				is_ua_adult_preadult = yes
			}
		}
	}

	immediate = {
		if = {
			limit = {
				OR = {
					is_adult = no
					is_ua_adult_preadult = yes
				}
				OR = {
					age = 6
					age = 8
					age = 10
					age >= 11 #Backup in case something has gone wrong
				}
				number_of_personality_traits < childhood_personality_trait_gain_limit
			}
			if = {
				limit = {
					age = 6
					has_variable = reincarnation_of
					can_become_reincarnation_trigger = yes
				}
				trigger_event = child_personality.9900
			}
			else = {
				trigger_event = {
					on_action = child_personality_gain_ua
					days = { 1 360 }
				}
			}
		}
		every_courtier_or_guest = {
			limit = {
				OR = {
					is_adult = no
					is_ua_adult_preadult = yes
				}
				OR = {
					age = 6
					age = 8
					age = 10
					age >= 11 #Backup in case something has gone wrong
				}
				number_of_personality_traits < childhood_personality_trait_gain_limit
			}
			trigger_event = {
				on_action = child_personality_gain_ua
				days = { 1 360 }
			}
		}
		#Small random chance to acquire a fourth personality trait
		every_courtier_or_guest = {
			limit = {
				OR = {
					is_adult = no
					is_ua_adult_preadult = yes
				}
				number_of_personality_traits = childhood_personality_trait_gain_limit
				number_of_personality_traits < personality_trait_limit
			}
			random = {
				chance = childhood_fourth_personality_trait_chance
				trigger_event = {
					on_action = child_personality_gain_ua
					days = { 1 360 }
				}
			}
		}
		every_prisoner = {
			limit = {
				OR = {
					is_adult = no
					is_ua_adult_preadult = yes
				}
				OR = {
					age = 6
					age = 8
					age = 10
					age >= 11 #Backup in case something has gone wrong
				}
				number_of_personality_traits < childhood_personality_trait_gain_limit
			}
			trigger_event = {
				on_action = child_personality_gain_ua
				days = { 1 360 }
			}
		}
		#Small random chance to acquire a fourth personality trait
		every_prisoner = {
			limit = {
				OR = {
					is_adult = no
					is_ua_adult_preadult = yes
				}
				number_of_personality_traits = childhood_personality_trait_gain_limit
				number_of_personality_traits < personality_trait_limit
			}
			random = {
				chance = childhood_fourth_personality_trait_chance
				trigger_event = {
					on_action = child_personality_gain_ua
					days = { 1 360 }
				}
			}
		}
	}
}